/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package multithreading.aps;

import java.util.Random;

/**
 *
 * @author leovirgilio
 */
public class Vendedor implements Runnable{
    private static Random generator = new Random();
    private Buffer sharedLocation;

    public Vendedor(Buffer sharedLocation) {
        this.sharedLocation = sharedLocation;
    }
    
    public void run(){
        int sum = 0;
        
        for(int count =1; count <=10; count ++){
            try{
                Thread.sleep((generator.nextInt(1000)));
                sharedLocation.set(count);
                sum+=count;
            }catch(InterruptedException ex){
                ex.printStackTrace();
            }
        }
        System.out.println("Vendedor fez sua venda!");
    }
   
    
}
